<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <link rel="shortcut icon" href="<!--{eval echo register_static('img/touch-icon-57x57.png');}-->">
    <title>粉粉管理系统</title>

    <!-- Bootstrap core CSS -->
    <link href="<!--{eval echo register_static('css/bootstrap.min.css');}-->" rel="stylesheet">
    <link href="<!--{eval echo register_static('css/bootstrap-reset.css');}-->" rel="stylesheet">
    <!--Animation css-->
    <link href="<!--{eval echo register_static('css/animate.css');}-->" rel="stylesheet">
    <!--Icon-fonts css-->
    <link href="<!--{eval echo register_static('assets/font-awesome/css/font-awesome.css');}-->" rel="stylesheet" />
    <link href="<!--{eval echo register_static('assets/ionicon/css/ionicons.min.css');}-->" rel="stylesheet" />
    <link href="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.css');}-->" rel="stylesheet">
    <link href="<!--{eval echo register_static('assets/tagsinput/jquery.tagsinput.css');}-->" rel="stylesheet">
    <!-- Plugins css -->
    <link href="<!--{eval echo register_static('assets/modal-effect/css/component.css');}-->" rel="stylesheet">
    <!-- DataTables -->
    <link rel="stylesheet" href="<!--{eval echo register_static('assets/datatables/jquery.dataTables.min.css" rel="stylesheet');}-->" />
    <!-- Custom styles for this template -->
    <link href="<!--{eval echo register_static('css/style.css');}-->" rel="stylesheet">
    <link href="<!--{eval echo register_static('css/helper.css');}-->" rel="stylesheet">
    <!-- My styles for this template -->
    <link href="<!--{eval echo register_static('css/common.css');}-->" rel="stylesheet"></head>

<body>

    <!-- Aside Start-->
    <!--{template admin_v2/leftside}-->
    <!-- Aside Ends-->

    <!--Main Content Start -->
    <section class="content">

        <!-- Header -->
        <!--{template admin_v2/header}-->
        <!-- Header Ends -->

        <!-- Page Content Start -->
        <!-- ================== -->

        <div class="wraper container-fluid user-list">

            <div class="row">
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">多账号操作</h3>
                        </div>
                        <div class="panel-body">
                            <form class="form-horizontal" id="sendForm">
                                <div class="form-group">
                                    <label for="inputUid" class="col-sm-2 control-label">接收用户UID</label>
                                    <div class="col-sm-10">
                                        <input type="text" name="uids" class="form-control"  id="inputUid" placeholder="键入用户UID，enter键确认">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputContent" class="col-sm-2 control-label">内容</label>
                                    <div class="col-sm-10">
                                        <textarea name="content"  cols="30" rows="10"  class="form-control" id="inputContent" placeholder="0-140字以内"></textarea>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputType" class="col-sm-2 control-label">发送类型</label>
                                    <div class="col-sm-10">
                                        <select name="type" id="inputType" class="form-control">
                                            <option value="1">内容</option>
                                            <option value="2">金币</option>
                                            <option value="3">经验</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group" id="send_num">

                                </div>
                                <div class="form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                        <button type="button" class="btn btn-primary" id="sendmessage">发送</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

                </div>
                <!-- Footer Start -->
                <!--{template admin_v2/footer}-->
                <!-- Footer Ends --> </section>
            <!-- Main Content Ends -->

            <!-- js placed at the end of the document so the pages load faster -->
            <script src="<!--{eval echo register_static('js/jquery.js');}-->"></script>
            <script src="<!--{eval echo register_static('js/bootstrap.min.js');}-->"></script>
            <script src="<!--{eval echo register_static('js/pace.min.js');}-->"></script>
            <script src="<!--{eval echo register_static('js/wow.min.js');}-->"></script>
            <script src="<!--{eval echo register_static('js/jquery.nicescroll.js');}-->" type="text/javascript"></script>

            <script src="<!--{eval echo register_static('js/jquery.app.js');}-->"></script>

            <script src="<!--{eval echo register_static('assets/datatables/jquery.dataTables.min.js');}-->"></script>
            <script src="<!--{eval echo register_static('assets/datatables/dataTables.bootstrap.js');}-->"></script>
            <script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.js');}-->"></script>
            <script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.init.js');}-->"></script>
            <script src="<!--{eval echo register_static('assets/tagsinput/jquery.tagsinput.min.js');}-->"></script>

            <!-- Modal-Effect -->
            <script src="<!--{eval echo register_static('assets/modal-effect/js/classie.js');}-->"></script>
            <script src="<!--{eval echo register_static('assets/modal-effect/js/modalEffects.js');}-->"></script>

            <!--layui-->
            <script src="<!--{eval echo register_static('layer/layer.js');}-->"></script>
            <script src="<!--{eval echo register_static('laytpl/laytpl.js');}-->"></script>


            <script type="application/javascript">

                $(document).ready(function() {
                    // 设置table配置
                    $('#datatable').dataTable({
                        "iDisplayLength": 50,
                        "aLengthMenu": [10, 20, 50, 100],
                        "searching": false,
                        "bLengthChange": false,
                        "bSort": false,
                        "bPaginate": false
                    });
                    $.fn.serializeObject = function(){
                        var o = {};
                        var a = this.serializeArray();
                        $.each(a, function() {
                            if (o[this.name] !== undefined) {
                                if (!o[this.name].push) {
                                    o[this.name] = [o[this.name]];
                                }
                                o[this.name].push(this.value || '');
                            } else {
                                o[this.name] = this.value || '';
                            }
                        });
                        return o;
                    };
                });

                $(function(){
                    $('#inputUid').tagsInput({'defaultText':'输入UID'});
                    $(document).off('click','#sendmessage').on('click','#sendmessage',function () {
                           var data={};
                           var d = $('#sendForm').serializeArray();
                           for(var i in d){
                               data[d[i].name] = d[i].value;
                           }
                           data['action'] = 'sendMessage';
                           request(data,resDisplay);
                    });
                });
                $(document).off('change','#inputType').on('change','#inputType',function(){
                     var type = $(this).val();
                     if(type == '1'){
                         $('#send_num').html('');
                     }
                     if(type == '2' || type == '3'){
                        var h = '<label for="send_number" class="col-sm-2 control-label">金币或经验</label> <div class="col-sm-10"> <input type="text" class="form-control" id="send_number" name="number" placeholder="金币数或经验数,记得选对类型"></div>'
                         $('#send_num').html(h);
                     }
                });
                var request = function(data, func, method, url){
                    layer.load();
                    url    ? url    : url    = 'admin.php?ac=admin';
                    method ? method : method = 'GET';
                    data['do'] = 'accountsOperation';
                    data['op'] = 'start';
                    $.ajax({
                        dataType : 'json',
                        url  : url,
                        type : method,
                        data : data,
                        success: function(returnData){
                            layer.closeAll();
                            func(returnData.result);
                        }
                    });
                }
               var resDisplay = function(data){
                   var str = '';
                   if(data == true){
                       str = '操作成功!';
                   }else{
                       str = '操作失败!';
                   }
                   setTimeout(function(){
                       layer.msg(str);
                       window.location.href="admin.php?ac=admin&do=accountsOperation";
                   },1000);
               }

             </script>
</body>
        </html>